190A - Vasya and the Bus - CodeForces Solution


greedy math *1100

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int child, men;
        cin>>men>>child;
        {
            if(men==0 && child!=0)
            {
                cout<<"Impossible"<<endl;
                return;
            }
            if(child==0)
            {
                cout<<men<<" "<<men<<endl;
                return;
            }
            if(men==child)
            {
                cout<<men<<" "<<men+child-1<<endl;
                return;
            }
            if(men>child)
            {
                cout<<men<<" "<<men+child-1<<endl;
                return;
            }
            if(child>men)
            {
                cout<<men+(child-men)<<" "<<men+child-1<<endl;
            }
        }
}
int main()
{
    cin.tie(0);cin.sync_with_stdio(0);
    cout.tie(0);cout.sync_with_stdio(0);
    int t = 1;
    while (t--)
    {
        solve();
        
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

1350A - Orac and Factors
1373A - Donut Shops
26A - Almost Prime
1656E - Equal Tree Sums
1656B - Subtract Operation
1656A - Good Pairs
1367A - Short Substrings
87A - Trains
664A - Complicated GCD
1635D - Infinite Set
1462A - Favorite Sequence
1445B - Elimination
1656C - Make Equal With Mod
567A - Lineland Mail
1553A - Digits Sum
1359B - New Theatre Square
766A - Mahmoud and Longest Uncommon Subsequence
701B - Cells Not Under Attack
702A - Maximum Increase
1656D - K-good
1426A - Floor Number
876A - Trip For Meal
1326B - Maximums
1635C - Differential Sorting
961A - Tetris
1635B - Avoid Local Maximums
20A - BerOS file system
1637A - Sorting Parts
509A - Maximum in Table
1647C - Madoka and Childish Pranks